
import tensorflow as tf

with tf.Session() as sess:
    x = tf.constant([[1, 2, 3], [4, 5, 6]])
    x_T = tf.transpose(x)  # [[1, 4]
                     #  [2, 5]
                     #  [3, 6]]
    print(sess.run(x))
    print(sess.run(x_T))

    indices = tf.Variable(tf.zeros([4], dtype=tf.int32))
    # x = tf.Variable([1, 2, 3])
    sess.run(indices.initializer)
    indices = tf.reshape(indices, [1, 4])
    print("indices:{}".format(sess.run(indices)))
    indices_T = tf.transpose(indices,perm=[1,0])
    print("indices T :{}".format(sess.run(indices_T)))
